package services.snipeit

import com.typesafe.config.Config
import play.api.ConfigLoader

case class SnipeITConfig(url:String="",user:String="",password:String="",apikey:String="",gid:Int=0)

object SnipeITConfig {
  implicit val configLoader:ConfigLoader[SnipeITConfig] = new ConfigLoader[SnipeITConfig] {
    override def load(config: Config, path: String): SnipeITConfig = {
      val conf = if (path.isEmpty){
        config.getConfig("snipe.config.default")
      }else{
        config.getConfig("snipe.config."+path)
      }
      SnipeITConfig(
        url = conf.getString("url"),
        user = conf.getString("user"),
        password = conf.getString("password"),
        apikey = conf.getString("ApiKey"),
        gid = conf.getInt("gid")
      )
    }
  }
}
